<template>
  <div class="container">
    <DocHeader :title="title" :diagnosis="true" />
    <div class="content">
      <div class="flex bort borb borl">
        <div class="flex-1 borr tac pad8">项目</div>
        <div class="flex flex-7">
          <div class="flex-5 borr tac pad8">内容</div>
          <div class="flex-1 borr tac pad8">执行打钩</div>
          <div class="flex-1 borr tac pad8">备注</div>
        </div>
      </div>
      <!--  -->
      <div
        v-for="itemss in pageData.list"
        :key="itemss.title"
        class="flex borl"
      >
        <div class="flex-1 borr tac pad8 rl borb">{{ itemss.title }}</div>
        <div class="flex-7">
          <div
            v-for="items in itemss.list"
            :key="items.title"
            class="flex borb"
          >
            <div class="flex-5 borr tac pad8">
              {{ items.title }}
            </div>
            <div class="flex-1 borr tac pad8">
              <el-checkbox v-model="items.check"></el-checkbox>
            </div>
            <div class="flex-1 borr tac pad8">
              <el-input v-model="items.value" class="input"></el-input>
            </div>
          </div>
        </div>
      </div>
      <!--  -->
      <div class="flex borl borr borb">
        <div class="flex-1 borr tac pad8">其他</div>
        <div class="flex flex-7 tac">
          <el-input v-model="pageData.other" class="input"></el-input>
        </div>
      </div>
      <!--  -->
      <div class="flex borl borr borb">
        <div class="flex-1 borr tac pad8">执行护士签名</div>
        <div class="flex flex-7 tac">
          <el-input v-model="pageData.nurseSign" class="input"></el-input>
        </div>
      </div>
      <!--  -->
      <div class="flex sign">
        <div class="patient flex">
          <div class="title" @click="getParams">患者：</div>
          <div>
            <el-input
              v-model="pageData.patientSign"
              style="width: 120px"
              class="input"
            ></el-input>
          </div>
        </div>
        <div class="nurse flex">
          <div class="title">操作人员签名：</div>
          <div>
            <el-input
              v-model="pageData.opSign"
              style="width: 100px"
              class="input"
            ></el-input>
          </div>
        </div>
        <div class="time flex">
          <div class="title">日期：</div>
          <div>
            <el-input
              v-model="pageData.time"
              style="width: 180px"
              class="input"
            ></el-input>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { cloneDeep } from 'lodash-unified'
import {
  defineComponent,
  nextTick,
  onMounted,
  reactive,
  toRefs,
  watch
} from 'vue'

import DocHeader from '../DocHeader.vue'
import { baseData } from './baseData.js'

export default defineComponent({
  components: {
    DocHeader
  },
  props: {
    data: {
      type: Object,
      default: () => ({})
    },
    patCur: {
      type: Object,
      default: () => ({})
    },
    formType: {
      type: String,
      default: 'add'
    },
    type: {
      type: String,
      default: ''
    },
    idx: {
      type: Number,
      default: 0
    },
    title: {
      type: String,
      default: ''
    }
  },
  setup(props) {
    const state = reactive({
      pageData: ''
    })

    function initData() {
      if (props.data.jsonText && props.data.jsonText !== '{}') {
        const jsonText = JSON.parse(props.data.jsonText)
        state.pageData = Object.assign(cloneDeep(baseData()), jsonText)
      } else {
        nextTick(() => {
          state.pageData = baseData()
        })
      }
    }

    function getParams() {
      return state.pageData
    }

    watch(
      () => props.data,
      () => {
        initData()
      }
    )

    onMounted(() => {
      initData()
    })

    return {
      ...toRefs(state),
      getParams
    }
  }
})
</script>

<style lang="scss" scoped>
@import '@/views/doc/styles/doc-common.scss';
$border: 1px solid #000;

::v-deep .el-checkbox {
  margin: 0 8px !important;
}

.container {
  padding: getpx(80);
  // margin: getpx(30) auto 0;
  // width: calc(100% - 86px);
  font-family: SiYuanSong-Medium;
  text-align: start;

  .content {
    margin-top: 20px;
  }
}

.input {
  width: 80%;

  :deep {
    .el-input__inner {
      border: none;
      font-size: 13px;
      color: #000;
      padding: 0;
      line-height: 1;
      height: 16px;
    }
  }
}

.rl {
  writing-mode: vertical-rl;
}

.flex {
  display: flex;
}

.tac {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.sta {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.flex {
  @for $i from 1 through 30 {
    &-#{$i} {
      flex: $i;
    }
  }
}

.sign {
  flex-flow: column nowrap;
  align-items: flex-end;
  margin-top: 50px;
  line-height: 32px;

  & > div {
    width: 38%;
  }

  .title {
    height: 32px;
  }
}

.mb8 {
  margin-bottom: 8px;
}

.borr {
  border-right: 1px solid #000;
}

.bort {
  border-top: 1px solid #000;
}

.borl {
  border-left: 1px solid #000;
}

.borb {
  border-bottom: 1px solid #000;
}

.pad10 {
  padding: 10px;
}

.pad8 {
  padding: 8px;
}
</style>
